﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using SYcwpb.ViewModels;
using SYcwpb.Helpers;
using SYcwpb.Models;

namespace SYcwpb.Views
{
    /// <summary>
    /// DriverAttendanceOrderAdjustView.xaml 的交互逻辑
    /// </summary>
    public partial class DriverAttendanceOrderAdjustView : Window
    {
        private static DriverAttendanceOrderAdjustView _view = null;

        private DriverAttendanceOrderAdjustViewModel _viewModel;
        private DriverAttendanceOrderAdjustView()
        {
            InitializeComponent();

            _viewModel = new DriverAttendanceOrderAdjustViewModel(this);

            this.DataContext = _viewModel;
        }

        public static DriverAttendanceOrderAdjustView GetInstance()
        {
            if (null == _view ||WindowHelper.IsDisposed(_view))
            {
                _view = new DriverAttendanceOrderAdjustView();
            }

            return _view;
        }

        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MessageBoxHelper.ShowTips((sender as ComboBox).SelectedItem.ToString());
            //_viewModel.GetCertainGroup((sender as ComboBox).SelectedItem.ToString());
            _viewModel.GetAttendances();
        }

        private void ContextMenu_Click(object sender, RoutedEventArgs e)
        {
            DriverAttendanceOrderAdjustModel model = dataGrid.SelectedItem as DriverAttendanceOrderAdjustModel;

            _viewModel.DeleItem( model);
        }
    }
}
